package com.abc.service;

import com.abc.entity.Yuanxi;
import com.abc.mapper.YuanxiMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class YuanxiService {

    @Autowired
    private YuanxiMapper yuanxiMapper;

    public List<Yuanxi> findAllYuanxi(){
        return yuanxiMapper.findAllYuanxi();
    }
    public String addYuanxi(Yuanxi yuanxi){
        Yuanxi yaunxi1 = yuanxiMapper.findByYuanxiMingcheng(yuanxi.getMingcheng());
        if(yaunxi1!=null){
            return "名称已存在,添加失败";
        }
        int k = yuanxiMapper.insertYuanxi(yuanxi);
        if(k>0){
            return "添加成功";
        }else{
            return "添加失败";
        }
    }

}
